<?php
    $title = "تعديل بيانات مستخدم";
    include_once '../../Common/View/Header.php'; 
    include_once '../Model/M_EditUser.php';
    if(empty($_GET))
    {
        echo '<br/><br/><center><h1><font color=red> لايمكنك فتح هذه الصفحة بهذه الطريقة, يجب اختيار مستخدم لتعديل بياناته </font><h1></center>';  
        header('Location:../View/ListUser.php');
    }else{
        $username = $_GET['username'];
        $user = new User();
        $user->getAdminData($username);
?>
<div id="site_content">
    <div id="content">
        <h1></h1>
        <form id="user_regestration" action="../Controller/C_EditUser.php?action=edit&username=<?php echo $username ?>" method="post"onsubmit="return validation()">
          <div class="form_settings">
            <p><b><span>الاسم الاول</span></b><input class="contact" type="text" id="first_name" name="first_name" value="<?php echo $user->adminData[0]["first_name"]; ?>" maxlength ="25" onblur="return isName('first_name')"/><font color="red">*</font><dev id='first_nameErr'></dev></p>
            <p><b><span>اسم الاب</span></b><input class="contact" type="text" name="father_name" value="<?php echo $user->adminData[0]["father_name"]; ?>" maxlength ="25" onblur="return isName('father_name')"/><font color="red">*</font><dev id='father_nameErr'></dev></p>
            <p><b><span>العائلة</span></b><input class="contact" type="text" name="family_name" value="<?php echo $user->adminData[0]["grandfather_name"]; ?>" maxlength ="25" onblur="return isName('family_name')"/><font color="red">*</font><dev id='family_nameErr'></dev></p>
            <p><b><span>اسم المستخدم</span></b><input class="contact" type="text" name="username" value="<?php echo $user->adminData[0]["username"]; ?>" maxlength ="15" onblur="return isUsername()"/><font color="red">*</font><dev id='family_nameErr'></dev></p>
            <p><b><span>البريد الالكتروني</span></b><input class="contact" type="text" name="email" value="<?php echo $user->adminData[0]["email"]; ?>" onblur="return isEmail()"/><font color="red">*</font><dev id='EmailErr'></dev></p>
            <p style="padding-top: 15px"><span>&nbsp;</span><input class="submit" type="submit" name="user_submitted" value="تحديث" /></p>
          </div>
        </form>
        <?php
            //session_start();
            include'../../Common/Model/ErrorMsg.php';
            if(isset($_SESSION['UserData'])){
                if($_SESSION['UserData']==true)
                {
                     echo '<br/><b><font color=green size=3>'.$correctData.'</font></b>';
                     unset($_SESSION['UserData']);                    
                }
                elseif($_SESSION['UserData']==false)
                {
                     echo '<br/><b><font color=red size=3>'.$incorrectData.'</font></b>';
                     unset($_SESSION['UserData']);                    
                }
            }
        ?>
      </div>
    </div>
<?php include_once '../../Common/View/Footer.php'; } ?>